package br.com.medical.shop.web.controladores.servico;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.stereotype.Service;

@Service
public class OpenMeetingsService {

	public String getValue(String url,String tagElemento) {
		try {
		 	SAXReader reader = new SAXReader();
		 	Document doc = reader.read(url);
		 	Element root = doc.getRootElement();
		 	for ( Object studentObj : root.elements()) {
		 	    Element studentElement = (Element) studentObj;
		 	    return studentElement.elementText(tagElemento) != null ? studentElement.elementText(tagElemento).toString() :
		 	    	studentElement.getStringValue();
		 	}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
